<?php
namespace app\admin\validate;
use think\Validate;

class Users extends Validate
{
    protected $rule = [
        'username'=>  'require',
        'phone'   =>  'require|unique:Users',
        'depar_id'  =>  'require',
    ];
    protected $message =[
        'username.require'=>'用户名称不能为空',
        'phone.require'=>'电话号码部能为空',
        'phone.unique'=>'电话重复了',
        'depar_id.require'=>'部门必选',
    ];
    protected $scene = [
        'edit'  =>  [
            'username'=>'require',
            'phone'=>'require|unique:Users,phone^id',
            'depar_id'  =>  'require',
        ]
    ];
}